﻿// Example header text. Can be configured in the options.
using System;
using System.Data;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using vtech_frameWorks.Library;

namespace vtech_formBase
{
    public partial class frmPrintView : Telerik.WinControls.UI.RadForm
    {
        private DataSet dsObj;
        /// <summary>
        /// Đường dẫn báo cáo
        /// ví dụ: HPUITSOLOTION_System\Presentation Layers\Report\Custommer\RptCustommer.rpt
        /// </summary>
        private string Path = string.Empty;
        public frmPrintView(DataSet obj, string strPath, string strTitleForm)
        {
            this.InitializeComponent();
            this.dsObj = obj;
            this.Path = strPath;
            this.Text = strTitleForm;
        }

        private void frmPrintView_Load(object sender, EventArgs e)
        {
            ReportDocument rptDoc = new ReportDocument();
            string strPath = Application.StartupPath.Remove(Application.StartupPath.LastIndexOf(string.Format("{0}{1}", @"\", ClsConstants.ConfigKey.SolutionName)),
                                                                                                                                                                    Application.StartupPath.Length - Application.StartupPath.LastIndexOf(string.Format("{0}{1}", @"\", ClsConstants.ConfigKey.SolutionName)));
            rptDoc.Load(string.Format("{0}{1}{2}", strPath, @"\", this.Path));
            rptDoc.SetDataSource(this.dsObj);
            this.ReportViewer.ReportSource = rptDoc;
            this.ReportViewer.Show();
        }
    }
}